<template>
    <div class="box">
        <el-row>
            <el-col :span="22" :push="1">
                <div class="grid-content bg-purple">

                    <div class="kuang"></div>
                    <span style=" padding-left:40px;">用车申请</span>
                    <el-divider></el-divider>
                    <div style="margin-top: 20px; margin-left: 40px; width: 500px">
                        <el-form ref="form" :model="form" label-width="80px">
                            <el-form-item label="用车人">
                                <!-- 选择负责人start -->
                                <div class="avatar-uploader">
                                    <!-- 选中负责人后展示start -->
                                    <div v-if="selectedUser != ''">
                                        <img :src="selectedUser.icon" class="avatar" @click="headPage = true">
                                        <span style="position: relative;top: -17px;left: 20px;">{{ selectedUser.nickName
                                            }}
                                            <span style="margin-left: 26px;cursor: pointer;" @click="deUser">X</span>
                                        </span>
                                    </div>
                                    <!-- 选中负责人后展示end -->
                                    <!-- 负责人未选中展示 -->
                                    <i v-else @click="headPage = true" class="el-icon-plus avatar-uploader-icon"></i>
                                </div>
                            </el-form-item>

                            <el-dialog v-loading="loading" element-loading-text="拼命加载中"
                                element-loading-spinner="el-icon-loading"
                                element-loading-background="rgba(0, 0, 0, 0.8)" :visible.sync="headPage" width="50%"
                                :show-close="false">
                                <el-breadcrumb separator-class="el-icon-arrow-right">
                                    <!-- 步骤条start -->
                                    <el-breadcrumb-item v-for="(value, index) in headNavs" :key="index + 'e'"
                                        @click="upNav1(index)">
                                        <el-button v-if="persons.id == undefined" size="mini" style="border: 0px;"
                                            @click="upNav1(index)">{{ value }}</el-button>
                                    </el-breadcrumb-item>
                                    <!-- 步骤条end -->
                                    <br>
                                    <br>
                                    <br>
                                    <!-- 展示右边所选中的用户start -->
                                    <div style="float: right;margin-top: -70px;margin-right:30%;color: black;">
                                        已选择<span v-if="selectedUser != ''">1</span><span v-else>0</span>位联系人
                                        <br>
                                        <br>
                                        <br>
                                    </div>
                                    <!-- 展示选中的用户 -->
                                    <div v-if="selectedUser != ''" class="architecture"
                                        style="height: 50px;float: right;    position: relative;top: 12px;right: 50px;">
                                        <img style="width: 30px;height: 30px;position: relative;top: 10px;"
                                            :src="selectedUser.icon" />
                                        <span
                                            style="margin-left: 17%;color: black;color: black;font-size: 10px;display: block;margin-top: -20px;">
                                            {{ selectedUser.nickName }}<br><br>
                                            {{ selectedUser.tposition.deptName }}
                                            <span
                                                style="float: right;margin-top: -10px;margin-right: 20px;cursor: pointer;"
                                                @click="deUser">X</span>
                                        </span>

                                    </div>
                                    <!-- 展示右边所选中的用户end -->
                                    <!-- 展示左边信息start -->
                                    <!-- 展示部门和人数start -->
                                    <div class="architecture" style="line-height: 39px;"
                                        v-for="(value, perIndex) in persons" :key="perIndex"
                                        @click="selectArchitecture(value.deptName)">
                                        <div class="log">
                                            <img
                                                src="https://cdn7.axureshop.com/demo2023/2236859/images/%E8%AF%B7%E5%81%87/u2303.svg" />
                                        </div>
                                        <span style="margin-left: 5%;color: black;">
                                            {{ value.deptName }}
                                        </span>
                                        &nbsp;&nbsp;&nbsp;({{ value.deptCount }})
                                        <span style="float: right;margin-right: 20px;">
                                            ＞
                                        </span>
                                    </div>
                                    <!-- 展示部门和人数end -->
                                    <br>
                                    <!-- 展示当前所选部门的所有用户start -->
                                    <div v-if="users.length != 0">
                                        <div :class="[selectArchitectureCss != userIndex ? 'architecture' : '', selectArchitectureCss == userIndex ? 'architectureActe' : '']"
                                            style="height: 50px;" v-for="(myUser, userIndex) in users" :key="userIndex"
                                            @click="selectUser(userIndex)">
                                            <el-radio style="width: 80%;height: 100%;" v-model="selectId"
                                                :label="userIndex">
                                                &nbsp;&nbsp;&nbsp;
                                                <img style="width: 30px;height: 30px;position: relative;top: 10px;"
                                                    :src="myUser.icon" />
                                                <span
                                                    style="margin-left: 5%;color: black;font-size: 10px;float: left;position: relative;top: 12px;left: 110px;">
                                                    {{ myUser.nickName }}<br><br>
                                                    {{ myUser.tposition.deptName }}
                                                </span>

                                            </el-radio>
                                            <span>
                                                ＞
                                            </span>
                                        </div>
                                    </div>
                                    <!-- 展示当前所选部门的所有用户start -->
                                    <!-- 展示左边信息end -->

                                </el-breadcrumb>

                                <!-- 竖直分割线 -->
                                <div class="myHr"></div>


                                <span slot="footer" class="dialog-footer">
                                    <el-button @click="headPage = false">取 消</el-button>
                                    <el-button type="primary" @click="headPage = false">确 定</el-button>
                                </span>
                            </el-dialog>
                            <!-- 选择负责人end -->
                            <el-form-item label="选择车辆">
                                <el-select v-model="form.carId" placeholder="选择车辆">
                                    <span v-for="(item, index) in carNumbers" :key="index">
                                        <el-option :label="item.carNumber" :value="item.id"></el-option>
                                    </span>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="开始时间">
                                <el-date-picker value-format="yyyy-MM-dd HH:mm:ss" v-model="form.carStartTime"
                                    type="datetime" placeholder="选择日期时间">
                                </el-date-picker>
                            </el-form-item>
                            <el-form-item label="结束时间">
                                <el-date-picker value-format="yyyy-MM-dd HH:mm:ss" v-model="form.carEndTime"
                                    type="datetime" placeholder="选择日期时间">
                                </el-date-picker>
                            </el-form-item>
                            <el-form-item label="始发地">
                                <el-input v-model="form.carDestination" placeholder="请输入内容"></el-input>
                            </el-form-item>
                            <el-form-item label="目的地">
                                <el-input v-model="form.carOforigin" placeholder="请输入内容"></el-input>
                            </el-form-item>
                            <el-form-item label="用车事由">
                                <el-input type="textarea" maxlength="100" show-word-limit
                                    v-model="form.carCause"></el-input>
                            </el-form-item>
                            <el-form-item label="内部乘车人" label-width="100">
                                <!-- 选择负责人start -->
                                <div class="avatar-uploader">
                                    <!-- 选中负责人后展示start -->
                                    <div v-if="selectedUser1 != ''">
                                        <img :src="selectedUser1.icon" class="avatar" @click="headPage1 = true">
                                        <span style="position: relative;top: -17px;left: 20px;">{{
                selectedUser1.nickName }}
                                            <span style="margin-left: 26px;cursor: pointer;" @click="deUser1">X</span>
                                        </span>
                                    </div>
                                    <!-- 选中负责人后展示end -->
                                    <!-- 负责人未选中展示 -->
                                    <i v-else @click="headPage1 = true" class="el-icon-plus avatar-uploader-icon"></i>
                                </div>
                            </el-form-item>

                            <el-dialog v-loading="loading1" element-loading-text="拼命加载中"
                                element-loading-spinner="el-icon-loading"
                                element-loading-background="rgba(0, 0, 0, 0.8)" :visible.sync="headPage1" width="50%"
                                :show-close="false">
                                <el-breadcrumb separator-class="el-icon-arrow-right">
                                    <!-- 步骤条start -->
                                    <el-breadcrumb-item v-for="(value, index) in headNavs1" :key="index + 'e'"
                                        @click="upNav1(index)">
                                        <el-button v-if="persons1.id == undefined" size="mini" style="border: 0px;"
                                            @click="upNav1(index)">{{ value }}</el-button>
                                    </el-breadcrumb-item>
                                    <!-- 步骤条end -->
                                    <br>
                                    <br>
                                    <br>
                                    <!-- 展示右边所选中的用户start -->
                                    <div style="float: right;margin-top: -70px;margin-right:30%;color: black;">
                                        已选择<span v-if="selectedUser1 != ''">1</span><span v-else>0</span>位联系人
                                        <br>
                                        <br>
                                        <br>
                                    </div>
                                    <!-- 展示选中的用户 -->
                                    <div v-if="selectedUser1 != ''" class="architecture"
                                        style="height: 50px;float: right;    position: relative;top: 12px;right: 50px;">
                                        <img style="width: 30px;height: 30px;position: relative;top: 10px;"
                                            :src="selectedUser1.icon" />
                                        <span
                                            style="margin-left: 17%;color: black;color: black;font-size: 10px;display: block;margin-top: -20px;">
                                            {{ selectedUser1.nickName }}<br><br>
                                            {{ selectedUser1.tposition.deptName }}
                                            <span
                                                style="float: right;margin-top: -10px;margin-right: 20px;cursor: pointer;"
                                                @click="deUser1">X</span>
                                        </span>

                                    </div>
                                    <!-- 展示右边所选中的用户end -->
                                    <!-- 展示左边信息start -->
                                    <!-- 展示部门和人数start -->
                                    <div class="architecture" style="line-height: 39px;"
                                        v-for="(value, perIndex) in persons1" :key="perIndex"
                                        @click="selectArchitecture1(value.deptName)">
                                        <div class="log">
                                            <img
                                                src="https://cdn7.axureshop.com/demo2023/2236859/images/%E8%AF%B7%E5%81%87/u2303.svg" />
                                        </div>
                                        <span style="margin-left: 5%;color: black;">
                                            {{ value.deptName }}
                                        </span>
                                        &nbsp;&nbsp;&nbsp;({{ value.deptCount }})
                                        <span style="float: right;margin-right: 20px;">
                                            ＞
                                        </span>
                                    </div>
                                    <!-- 展示部门和人数end -->
                                    <br>
                                    <!-- 展示当前所选部门的所有用户start -->
                                    <div v-if="users1.length != 0">
                                        <div :class="[selectArchitectureCss1 != userIndex ? 'architecture' : '', selectArchitectureCss1 == userIndex ? 'architectureActe' : '']"
                                            style="height: 50px;" v-for="(myUser1, userIndex) in users1"
                                            :key="userIndex" @click="selectUser1(userIndex)">
                                            <el-radio style="width: 80%;height: 100%;" v-model="selectId1"
                                                :label="userIndex">
                                                &nbsp;&nbsp;&nbsp;
                                                <img style="width: 30px;height: 30px;position: relative;top: 10px;"
                                                    :src="myUser1.icon" />
                                                <span
                                                    style="margin-left: 5%;color: black;font-size: 10px;float: left;position: relative;top: 12px;left: 110px;">
                                                    {{ myUser1.nickName }}<br><br>
                                                    {{ myUser1.tposition.deptName }}
                                                </span>

                                            </el-radio>
                                            <span>
                                                ＞
                                            </span>
                                        </div>
                                    </div>
                                    <!-- 展示当前所选部门的所有用户start -->
                                    <!-- 展示左边信息end -->

                                </el-breadcrumb>

                                <!-- 竖直分割线 -->
                                <div class="myHr"></div>


                                <span slot="footer" class="dialog-footer">
                                    <el-button @click="headPage1 = false">取 消</el-button>
                                    <el-button type="primary" @click="headPage1 = false">确 定</el-button>
                                </span>
                            </el-dialog>
                            <!-- 选择负责人end -->
                        </el-form>
                    </div>
                    <div class="kuang"></div>
                    <span style=" padding-left:40px;">审批记录</span>
                    <div style="height: 300px; margin-top: 30px;">
                        <el-timeline>
                            <el-timeline-item color="#409EFF">发起</el-timeline-item>
                            <el-timeline-item color="#67C23A">
                                审批人 &nbsp;&nbsp;
                                <el-tag size="small" effect="plain">依次审批</el-tag>
                                <br /><br />
                                <!-- <el-select v-model="form.approver" multiple placeholder="请选择" style="width:100px">
                                    <el-option v-for="item in options" :key="item.id" :label="item.nickName"
                                        :value="item.id">
                                    </el-option>
                                </el-select> -->
                                <div  class="avatar-uploader">
                                        <!-- 选中负责人后展示start -->
                                        <div style="display: inline;" v-if="unSelectedUsers!=''">
                                            <div style="display: inline;" v-for="selectedUser,index in unSelectedUsers" :key="index">
                                                <img style="vertical-align: middle;"   :src="selectedUser.icon" class="avatar" @click="getUnSelectIdPage()">
                                                <i style="position: relative;bottom: 13px;right: 12px;border-radius: 50%;background-color: #c0c4cc;color: white;" @click="unDeUser(index)" class="el-icon-close"></i>
                                            </div>
                                        </div>
                                        
                                        <!-- 选中负责人后展示end -->
                                        <!-- 负责人未选中展示 -->
                                        <i v-else @click="getUnSelectIdPage()" class="el-icon-plus avatar-uploader-icon"></i>
                                    </div>
                                     <!-- 无需考勤 -->
                                    <el-dialog
                                        v-loading="loading"
                                        element-loading-text="拼命加载中"
                                        element-loading-spinner="el-icon-loading"
                                        element-loading-background="rgba(0, 0, 0, 0.8)"
                                        :visible.sync="unSelectIdPage"
                                        width="50%"
                                        :show-close="false">
                                        <div style="height: 200px;">
                                            <el-breadcrumb separator-class="el-icon-arrow-right">
                                                <!-- 步骤条start -->
                                                <el-breadcrumb-item  v-for="(value,index) in headNavs" :key="index+'E'" @click="upNav(index)">
                                                    <el-button v-if="persons.id==undefined" size="mini" style="border: 0px;" @click="upNav(index)">{{ value }}</el-button>
                                                </el-breadcrumb-item>
                                                <!-- 步骤条end -->
                                                <br>
                                                <br>
                                                <br>
                                                <!-- 展示右边所选中的用户start -->
                                                <div style="float: right;margin-top: -70px;margin-right:30%;color: black;">
                                                    已选择<span v-if="unSelectedUsers!=''">{{ unSelectedUsers.length }}</span><span v-else>0</span>位联系人
                                                    <br>
                                                    <br>
                                                    <br>
                                                </div>
                                                <!-- 展示选中的用户 -->
                                                <div v-for="selectedUser,index in unSelectedUsers" :key="index">
                                                    <div class="architecture" style="height: 50px;position: relative;top: 12px;left: 430px;">
                                                        <img style="width: 30px;height: 30px;position: relative;top: 10px;" :src="selectedUser.icon"/>
                                                        <span style="margin-left: 17%;color: black;color: black;font-size: 10px;display: block;margin-top: -20px;">
                                                            {{ selectedUser.nickName }}<br><br>
                                                            {{ selectedUser.tposition.deptName }}
                                                            <span style="float: right;margin-top: -10px;margin-right: 20px;cursor: pointer;" @click="unDeUser(index)">X</span>
                                                        </span>
                                                    </div>
                                                </div>
                                                
                                                <!-- 展示右边所选中的用户end -->
                                                <!-- 展示左边信息start -->
                                                <!-- 展示部门和人数start -->
                                                <div style="position: absolute; top: 100px;">
                                                    <div class="architecture" style="line-height: 39px;" v-for="(value,perIndex) in persons" :key="perIndex" @click="selectArchitecture(value.deptName)">
                                                        <div class="log">
                                                            <img src="https://cdn7.axureshop.com/demo2023/2236859/images/%E8%AF%B7%E5%81%87/u2303.svg" />
                                                        </div>
                                                        <span style="margin-left: 5%;color: black;">
                                                            {{ value.deptName }}
                                                        </span>
                                                        &nbsp;&nbsp;&nbsp;({{ value.deptCount }})
                                                        <span style="float: right;margin-right: 20px;">
                                                            ＞
                                                        </span>
                                                    </div>
                                                    <!-- 展示部门和人数end -->
                                                    <br>
                                                    <!-- 展示当前所选部门的所有用户start -->
                                                    <div v-if="users.length!=0">
                                                        <el-checkbox-group v-model="unSelectIds"  @change="unSelectUser()">
                                                            <div class="architecture" style="height: 50px;"  v-for="(myUser,userIndex) in users" :key="userIndex"   >
                                                                <el-checkbox style="width: 80%;height: 100%;" :label="myUser.id">
                                                                    &nbsp;&nbsp;&nbsp;
                                                                    <img style="width: 30px;height: 30px;position: relative;top: 10px;" :src="myUser.icon"/>
                                                                    <span style="margin-left: 5%;color: black;font-size: 10px;float: left;position: relative;top: 12px;left: 110px;">
                                                                        {{ myUser.nickName }}<br>
                                                                        {{ myUser.tposition.deptName }}
                                                                    </span>
                                                                    <span style="margin-top: 25px;margin-left: 120px;">
                                                                        ＞
                                                                    </span>
                                                                </el-checkbox>
                                                            </div>
                                                        </el-checkbox-group>
                                                    </div>
                                                    <!-- 展示当前所选部门的所有用户start -->
                                                    <!-- 展示左边信息end -->

                                                </div>

                                                                                            
                                            </el-breadcrumb>

                                            <!-- 竖直分割线 -->
                                            <div class="myHr"></div>
                                        </div>
                                        <span slot="footer" class="dialog-footer">
                                            <el-button @click="unSelectIdPage = false">取 消</el-button>
                                            <el-button type="primary" @click="unSelectIdPage = false">确 定</el-button>

                                        </span>

                                    </el-dialog>
                            </el-timeline-item>
                            <el-timeline-item color="#E6A23C">抄送人
                                <br /><br />
                                <!-- 选择抄送人start -->

                                <div class="avatar-uploader">
                                    <!-- 选中负责人后展示start -->
                                    <div v-if="selectedUser2 != ''">
                                        <img :src="selectedUser2.icon" class="avatar" @click="headPage2 = true">
                                        <span style="position: relative;top: -17px;left: 20px;">{{
                selectedUser2.nickName }}
                                            <span style="margin-left: 26px;cursor: pointer;" @click="deUser2">X</span>
                                        </span>
                                    </div>
                                    <!-- 选中抄送人后展示end -->
                                    <!-- 负责人未选中展示 -->
                                    <i v-else @click="headPage2 = true" class="el-icon-plus avatar-uploader-icon"></i>
                                </div>


                                <el-dialog v-loading="loading2" element-loading-text="拼命加载中"
                                    element-loading-spinner="el-icon-loading"
                                    element-loading-background="rgba(0, 0, 0, 0.8)" :visible.sync="headPage2"
                                    width="50%" :show-close="false">
                                    <el-breadcrumb separator-class="el-icon-arrow-right">
                                        <!-- 步骤条start -->
                                        <el-breadcrumb-item v-for="(value, index) in headNavs2" :key="index + 'a'"
                                            @click="upNav2(index)">
                                            <el-button v-if="persons2.id == undefined" size="mini" style="border: 0px;"
                                                @click="upNav2(index)">{{ value }}</el-button>
                                        </el-breadcrumb-item>
                                        <!-- 步骤条end -->
                                        <br>
                                        <br>
                                        <br>
                                        <!-- 展示右边所选中的用户start -->
                                        <div style="float: right;margin-top: -70px;margin-right:30%;color: black;">
                                            已选择<span v-if="selectedUser2 != ''">1</span><span v-else>0</span>位联系人
                                            <br>
                                            <br>
                                            <br>
                                        </div>
                                        <!-- 展示选中的用户 -->
                                        <div v-if="selectedUser2 != ''" class="architecture"
                                            style="height: 50px;float: right;    position: relative;top: 12px;right: 50px;">
                                            <img style="width: 30px;height: 30px;position: relative;top: 10px;"
                                                :src="selectedUser2.icon" />
                                            <span
                                                style="margin-left: 17%;color: black;color: black;font-size: 10px;display: block;margin-top: -20px;">
                                                {{ selectedUser2.nickName }}<br><br>
                                                {{ selectedUser2.tposition.deptName }}
                                                <span
                                                    style="float: right;margin-top: -10px;margin-right: 20px;cursor: pointer;"
                                                    @click="deUser2">X</span>
                                            </span>

                                        </div>
                                        <!-- 展示右边所选中的用户end -->
                                        <!-- 展示左边信息start -->
                                        <!-- 展示部门和人数start -->
                                        <div class="architecture" style="line-height: 39px;"
                                            v-for="(value, perIndex) in persons2" :key="perIndex"
                                            @click="selectArchitecture2(value.deptName)">
                                            <div class="log">
                                                <img
                                                    src="https://cdn7.axureshop.com/demo2023/2236859/images/%E8%AF%B7%E5%81%87/u2303.svg" />
                                            </div>
                                            <span style="margin-left: 5%;color: black;">
                                                {{ value.deptName }}
                                            </span>
                                            &nbsp;&nbsp;&nbsp;({{ value.deptCount }})
                                            <span style="float: right;margin-right: 20px;">
                                                ＞
                                            </span>
                                        </div>
                                        <!-- 展示部门和人数end -->
                                        <br>
                                        <!-- 展示当前所选部门的所有用户start -->
                                        <div v-if="users2.length != 0">
                                            <div :class="[selectArchitectureCss2 != userIndex ? 'architecture' : '', selectArchitectureCss2 == userIndex ? 'architectureActe' : '']"
                                                style="height: 50px;" v-for="(myUser, userIndex) in users2"
                                                :key="userIndex" @click="selectUser2(userIndex)">
                                                <el-radio style="width: 80%;height: 100%;" v-model="selectId2"
                                                    :label="userIndex">
                                                    &nbsp;&nbsp;&nbsp;
                                                    <img style="width: 30px;height: 30px;position: relative;top: 10px;"
                                                        :src="myUser.icon" />
                                                    <span
                                                        style="margin-left: 5%;color: black;font-size: 10px;float: left;position: relative;top: 12px;left: 110px;">
                                                        {{ myUser.nickName }}<br><br>
                                                        {{ myUser.tposition.deptName }}
                                                    </span>

                                                </el-radio>
                                                <span>
                                                    ＞
                                                </span>
                                            </div>
                                        </div>
                                        <!-- 展示当前所选部门的所有用户start -->
                                        <!-- 展示左边信息end -->

                                    </el-breadcrumb>

                                    <!-- 竖直分割线 -->
                                    <div class="myHr"></div>


                                    <span slot="footer" class="dialog-footer">
                                        <el-button @click="headPage2 = false">取 消</el-button>
                                        <el-button type="primary" @click="headPage2 = false">确 定</el-button>
                                    </span>
                                </el-dialog>
                                <!-- 选择负责人end -->
                            </el-timeline-item>
                        </el-timeline>
                        <el-row style=" position: relative;left:900px;top: -100px;">
                            <el-button type="primary" @click="onSubmit">立即提交</el-button>
                            <el-button @click="back">取消</el-button>
                        </el-row>
                    </div>
                </div>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import axios from "axios";
export default {
    data() {
        return {
            form: {
            },
            carNumbers: [],
            options: [],
            flag: false,
            // 获取负责人start
            headPage: false,//开启选择负责人页面
            headNavs: ["组织架构"],//步骤条
            persons: [],//部门和部门人数
            users: [],//所选部门的人员
            loading: false,//加载开启和关闭
            selectArchitectureCss: -1,//选中指定行后开启指定的css
            selectId: -1,//单选框
            selectedUser: "",//选中的用户
            replacementCard: {
                rulesName: "",
                replacementHead: "",
                replacementType: [],
                card: false,
            },
            //  获取负责人end
            // 获取乘车人start
            headPage1: false,//开启选择负责人页面
            headNavs1: ["组织架构"],//步骤条
            persons1: [],//部门和部门人数
            users1: [],//所选部门的人员
            loading1: false,//加载开启和关闭
            selectArchitectureCss1: -1,//选中指定行后开启指定的css
            selectId1: -1,//单选框
            selectedUser1: "",//选中的用户
            replacementCard1: {
                rulesName: "",
                replacementHead: "",
                replacementType: [],
                card: false,
            },

            //  获取乘车人end
            // 获取抄送人start
            headPage2: false,//开启选择抄送人页面
            headNavs2: ["组织架构"],//步骤条
            persons2: [],//部门和部门人数
            users2: [],//所选部门的人员
            loading2: false,//加载开启和关闭
            selectArchitectureCss2: -1,//选中指定行后开启指定的css
            selectId2: -1,//单选框
            selectedUser2: "",//选中的用户
            replacementCard2: {
                rulesName: "",
                replacementHead: "",
                replacementType: [],
                card: false,
            },

            // 无需考勤
            unSelectIdPage:false,//开启选择无需考勤页面
            unSelectIds:[],//多选无需考勤
            unSelectedUsers:[],//无需考勤选中的用户
            //  获取抄送人end
        };
    },
    created() {
        this.getCarNumber()
        this.getUserList();
        this.getDept();//获取部门
        this.getDept1();
        this.getDept2();
    },
    methods: {
        back(){
            this.$router.go(-1)
        },
        //id传一个当前登录人的id 没用了
        getUserList() { 
            axios.get("demo/findTUserList?id=" + 1)
                .then((res) => {
                    console.log(res);
                    this.options = res.data;
                })
        },
        //查询车牌号
        getCarNumber() {
            axios.get("/car/getCarNumber").then((res) => {
                console.log(res)
                this.carNumbers = res.data.data
            })
        },
        // 添加或者修改 方法
        onSubmit() {
            // var approver = "";
            // for (const value of this.form.approver) {
            //     approver == "" ? approver += value : approver += "," + value
            // }
            // this.form.approver = approver
            axios.post("/caruse/addCarUse", this.form).then((res) => {
                console.log(res);
                if (res.data.code === 200) {
                    this.$message.success(res.data.data);
                    this.$router.go(-1)
                } else {
                    this.$message.error(res.data.data);
                }
            });
        },
        // 负责人start
        // 更新步骤条
        upNav(index) {
            this.headNavs = this.headNavs.slice(0, index + 1);
            if ("组织架构" == this.headNavs) {
                this.loading = true;
                this.users = [];
                this.getDept();
            }
        },
        // 获取部门及部门人数
        getDept() {
            this.selectId = -1;
            this.deUser();
            axios.post("/ReplacementCard/findDept")
                .then((res) => {
                    this.persons = res.data.rows;
                    this.loading = false;
                })
        },
        // 获取所选择部门的用户信息
        selectArchitecture(value) {
            this.loading = true;
            this.persons = [];
            this.headNavs.push(value);
            var data = new FormData();
            data.append("name", value)
            axios.post("/ReplacementCard/findUserAndDept", data)
                .then((res) => {
                    this.users = res.data.rows;
                    if (this.users != []) {
                        this.loading = false;
                    }
                })

        },
        // 是否允许补卡更改重置和他相关联的值
        reset() {
            if (!this.replacementCard.card) {
                this.replacementCard.replacementCount = undefined;
                this.replacementCard.time = undefined;
            }

        },

        // 选中用户
        selectUser(index) {
            this.selectArchitectureCss = index;
            this.selectedUser = this.users[index];
            this.form.carUserId = this.selectedUser.id;
        },
        // 删除用户
        deUser() {
            this.selectId = -1;
            this.selectedUser = "";
            this.selectArchitectureCss = -1;
            this.form.carUserId = "";
        },
        // 负责人end

        // 乘车人start
        // 更新步骤条
        upNav1(index) {
            this.headNavs1 = this.headNavs1.slice(0, index + 1);
            if ("组织架构" == this.headNavs1) {
                this.loading1 = true;
                this.users1 = [];
                this.getDept1();
            }
        },
        // 获取部门及部门人数
        getDept1() {
            this.selectId1 = -1;
            this.deUser();
            axios.post("/ReplacementCard/findDept")
                .then((res) => {
                    this.persons1 = res.data.rows;
                    this.loading1 = false;
                })
        },
        // 获取所选择部门的用户信息
        selectArchitecture1(value) {
            this.loading1 = true;
            this.persons1 = [];
            this.headNavs1.push(value);
            var data = new FormData();
            data.append("name", value)
            axios.post("/ReplacementCard/findUserAndDept", data)
                .then((res) => {
                    this.users1 = res.data.rows;
                    if (this.users1 != []) {
                        this.loading1 = false;
                    }
                })

        },
        // 是否允许补卡更改重置和他相关联的值
        reset1() {
            if (!this.replacementCard1.card) {
                this.replacementCard1.replacementCount = undefined;
                this.replacementCard1.time = undefined;
            }

        },

        // 选中用户
        selectUser1(index) {
            this.selectArchitectureCss1 = index;
            this.selectedUser1 = this.users1[index];
            this.form.carRider = this.selectedUser1.id;
        },
        // 删除用户
        deUser1() {
            this.selectId1 = -1;
            this.selectedUser1 = "";
            this.selectArchitectureCss1 = -1;
            this.form.carRider = this.selectedUser1.id;
        },
        // 乘车人end

        // 抄送人start
        // 更新步骤条
        upNav2(index) {
            this.headNavs2 = this.headNavs2.slice(0, index + 1);
            if ("组织架构" == this.headNavs2) {
                this.loading2 = true;
                this.users2 = [];
                this.getDept2();
            }
        },
        // 获取部门及部门人数
        getDept2() {
            this.selectId2 = -1;
            this.deUser2();
            axios.post("/ReplacementCard/findDept")
                .then((res) => {
                    this.persons2 = res.data.rows;
                    this.loading2 = false;
                })
        },
        // 获取所选择部门的用户信息
        selectArchitecture2(value) {
            this.loading2 = true;
            this.persons2 = [];
            this.headNavs2.push(value);
            var data = new FormData();
            data.append("name", value)
            axios.post("/ReplacementCard/findUserAndDept", data)
                .then((res) => {
                    this.users2 = res.data.rows;
                    if (this.users2 != []) {
                        this.loading2 = false;
                    }
                })

        },
        // 是否允许补卡更改重置和他相关联的值
        reset2() {
            if (!this.replacementCard2.card) {
                this.replacementCard2.replacementCount = undefined;
                this.replacementCard2.time = undefined;
            }

        },

        // 选中用户
        selectUser2(index) {
            this.selectArchitectureCss2 = index;
            this.selectedUser2 = this.users2[index];
            this.form.carbon = this.selectedUser2.id;
        },
        // 删除用户
        deUser2() {
            this.selectId2 = -1;
            this.selectedUser2 = "";
            this.selectArchitectureCss2 = -1;
            this.form.carbon = this.selectedUser2.id;
        },
        // 抄送人end
        // 无需考勤用户
        unSelectUser(){
            if(this.unSelectedUsers.length>=3){
                this.unSelectedUsers = [];
                this.unSelectIds = [];
                this.$message({
                    type:"warning",
                    message:"最多只能选择三个"
                })
            }else{
                this.form.approver = this.unSelectIds.toString();
                for (const val of this.users) {
                    for (const id of this.unSelectIds) {
                        if(val.id==id){
                            if(this.unSelectedUsers.length==0){
                                this.unSelectedUsers.push(val);
                            }else{
                                let count = 0;
                                for (let i in this.unSelectedUsers) {
                                    if(this.unSelectedUsers[i].id==id){
                                        count++;
                                    }
                                    if(i==this.unSelectedUsers.length-1 && count==0){
                                        this.unSelectedUsers.push(val);
                                    }
                                }
                            }
                        }
                    }
                }
            }
           
            
        },
        // 删除
        unDeUser(index){
            this.unSelectIds.splice(index,1);
            
            let array = this.form.approver.split(",");
            for (let val in array) {
                if(array[val]==this.unSelectedUsers[index].id){
                    array.splice(val,1);
                }
            }
            this.form.approver = array.toString();
            this.unSelectedUsers.splice(index,1);

        },
        // 获取部门信息
        getUnSelectIdPage(){
            this.users = [];
            this.unSelectIdPage = true;
            this.headNavs = ["组织架构"];
            this.getDept();
        },

        
        // 考勤人员end
    },
};
</script>

<style scoped>
/* element-ui样式 */
.el-row {
    margin-bottom: 10px;

}

.el-col {
    border-radius: 4px;
}

.bg-purple {
    background: #fff;
    border-radius: 10px;
}

/* 自定义样式 */
/* * {
      margin: 0px;
      padding: 0px;
    } */
.box {
    width: 98%;
    height: 100%;
    margin: auto;
    /* background-color: red; */
}

.box_text {
    padding-top: 20px;
    /* padding-left: 40px; */
    margin-left: 40px;
    font-size: 16px;
}

/* 获取负责人start */
.avatar-uploader-icon[data-v-c59672b0] {
    border: 1px solid rgba(198, 201, 208, 1);
    background-color: rgba(248, 248, 248, 1);
    border-radius: 50%;
}

.avatar-uploader-icon {
    font-size: 20px;
    color: #8c939d;
    width: 50px;
    height: 50px;
    line-height: 50px;
    text-align: center;
}


.architecture {
    width: 271px;
    height: 39px;
    padding-left: 20px;
    border-radius: 5px;
}

.architecture:hover {
    background-color: #f8f8f8;
}

.architectureActe {
    width: 271px;
    height: 39px;
    line-height: 39px;
    padding-left: 20px;
    border-radius: 5px;
    background-color: rgba(231, 244, 255, 1);
    ;
}

/* 竖着的水平线 */
.myHr {
    border-left: 2px solid#989DAA;
    ;
    height: 100%;
    left: 48%;
    top: 0px;
    position: absolute;
}

.log {
    width: 27px;
    height: 27px;
    background-color: rgba(158, 208, 255, 1);
    float: left;
    position: relative;
    top: 15%;
    border-radius: 50%;
}

.log img {
    width: 13px;
    height: 13px;
    position: relative;
    bottom: 15%;
    left: 25%;
}

/* 获取负责人end */
.kuang {
    width: 4.5px;
    height: 25px;
    background-color: #409EFF;
    margin-left: 30px;
    position: relative;
    top: 23px;
}
</style>